<template>
  <div>
    <Spin :spinning="loading" tip="Loading...">
      <div style="padding-top: 1rem;"></div>

      <!-- table -->
      <!-- 回运旧件驳回原因 -->
      <FormPanel ref="formPanel" :list="formList1" :cols="1" :formType="'add'" labelWidth="110" :isSubmitBtn="false"  @formChange="formChangeHandle"/>

      <div style="padding-top: 1rem;"></div>
      <div
        :style="{
          position: 'absolute',
          left: 0,
          right: 0,
          zIndex: 9,
          borderTop: '1px solid #e9e9e9',
          padding: '10px 20px',
          background: '#fff',
          textAlign: 'right'
        }"
      >
        <multiuse-button type="primary" :click="saveDialog.bind()">驳回</multiuse-button>
        <multiuse-button @click="closeDialog">关 闭</multiuse-button>
      </div>
    </Spin>
  </div>

</template>
<script>
import { dictionary } from '@/utils/dictMixin';//字典的引入
//import { saveOne } from '@/api/claim/factory/guaranteeOil';
import { piLiangBuoHui } from '@/api/usedPartsReturnManage/usedPartsReturn_OEM/usedPartsWarehousing';

  export default {
  props: ['boHuiIds'],
    mixins: [dictionary],
    components: {
  
    },
    data() {
      return {
        returnMsg:null,
        dataList1: [],
        visible: false,
        visibleDrawer: false,
        collapse: false,
        visibleAdd:false,
        loading: false,
        fetchParams: {}, //ipa 接口
        selectedRows: [], //选中服务站
        formList1: this.createFormList1(),
        saveData: null,
        editData: {},

      };

    },
  async created() {
  // console.log(this.rowData.returnId,"this.rowData.returnId");
  //     await this.init(this.rowData.returnId);
     },
    methods: {
    // async init(val) {
    //   // console.log(this.rowData.returnId,"this.rowData.returnId");
    //  // let newVar = await selectById({id: val});
    //   this.editData = newVar.data;

    // },

      formChangeHandle(val) {
        console.log(val);
        this.saveData = val;
      },
      //搜索获取数据
      changeHandle(val) {
        this.fetchParams = val;
        console.log(val);
      },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
      // //保存
      // chooseModelName() {
      //   this.visibleDrawer = true;
      // },
      closeAdd() {
        this.visibleDrawer = false;
      },
      save(obj) {
        // this.formList1.find(x => x.fieldName == 'modelName').initialValue = obj[0].modelName;
        // this.formList1.find(x => x.fieldName == 'modelCode').initialValue = obj[0].modelCode;
        //this.modelName = obj[0].modelName;
        this.visibleDrawer = false;
      },
      saveAdd() {
        this.visibleDrawer = false;
        this.visibleAdd = false;
        this.fetchParams = { ...this.fetchParams };
      },
      //批量驳回保存 弹窗里点驳回按钮 调用批量驳回方法
      async saveDialog() {
          console.log(this.returnId,"returnId" );
          let str = '';
          this.boHuiIds.map(x => {
          str += x.returnId + ',';
          });

         console.log(str);
         let returnMsg = this.formList1.find(item => item.fieldName == 'returnMsg').initialValue;
         console.log(this.formList1.find(item => item.fieldName == 'returnMsg'),"yushiyaodameinv");

         const res = await piLiangBuoHui({ ids:str, status: 55881009,returnMsg : returnMsg});
        
          console.log(res);
          if (res.resultCode === 200) {
            this.$emit('save');
            return this.$notify.success({ title: '提示信息', message: '驳回成功' });
            this.fetchParams = { ...this.fetchParams };

          } else {
            this.loading = false;
            return this.$notify.error({title: '提示信息', message: '请检查是否填写驳回原因！'});
          }

        
    //批量驳回 

    
      },
      //取消操作
      closeDialog() {
        this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
      },


      createFormList1() {
        return [
          {
            type: 'TEXT_AREA',
            label: '驳回原因',
            fieldName: 'returnMsg',
            placeholder: '请输入驳回原因...',
            rows: 3,
            rules: [{ required: true, message: '请输入驳回原因', trigger: 'change' }],
            selfCols: 1 // 元素占据几行
          }

        ];
      }
    }
  };
</script>

<style lang="less" scoped></style>

